<script>
/*		
		
		$.ajax({
			type	: 'GET',
		    url 	: '/2013p79/common/class/search/ajax/json.search.php',
			dataType: 'JSON',	    
			data	: $('#frmSearch').serialize(),

			cache	: false,
			success	: function(data) {		
	
				for(var i=0; i < data.length ; i++) {
					var kk = '';
					var d  = data[i];
					var maker = d.maker, name = d.name, type = d.type, serial = d.serial, comment = d.comment ;
				
					makerStr[i] = maker;
			
					if( maker.search(/\(/))
						makerStr[i] = maker.split('(');		
					if( maker.search(/\' '/))					
						kk = makerStr[i][0].split(' ');	
						kk = kk[0];
								
					arrMaker[i] = "<a href='#" + kk + "' >" + kk + "</a>";
					arr[i] = "메이커: <a href= '#' id='"+ kk +"' >"+ maker + "</a> ****  프린터명: " + name ;
				}
				result = arr.join('<br />');
				
				$('#site_content').empty().append('<section id="makerPool">' + arrMaker.unique() + '</section>')
				.append('<section id="content_main">' + result + '</section>');    
				
			}  // EOF success		

		}); 
		return false;
/**/	



</script>
<?php
@header("Content-type: application/json; charset=utf-8");
require_once($_SERVER['DOCUMENT_ROOT'].'/2013p79/common/_init.php');
require_once(CLASS_PATH."/__autoload.php");

$arrStr = $arr = array();
$keyString = $_REQUEST['txtKeyString'];
$choice = $_REQUEST['choice'];

if($choice == 'printer')  
{
	$qry 	= new PrinterDAO;
	$result = $qry->get_details($keyString);
	
	while($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
	{
		$arr['maker'] 	= $row['pMaker'];
		$arr['type'] 	= $row['pType'];
		$arr['serial'] 	= $row['pSerial'];
		$arr['name'] 	= $row['pName'];
		$arr['comment'] = $row['pComment'];
		
		$arrStr[] = $arr;
	}
	
}
else if($choice == 'supplies')
{
	$qry 	= new SuppliesDAO;
	$result = $qry->get_details($keyString);
	
	while($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
	{
		$arr['maker'] 	= $row['sMaker'];
		$arr['type'] 	= $row['sType'];
		$arr['serial'] 	= $row['sSerial'];
		$arr['name'] 	= $row['sName'];
		$arr['comment'] = $row['sComment'];
		
		$arrStr[] = $arr;
	}
	
}

/*             // JSON.php 적용시
require_once($_SERVER['DOCUMENT_ROOT']."/2013p79/common/js/JSON.php");
$json = new Services_JSON();
$output = $json->encode($arrStr);     
/**/

$output = json_encode($arrStr);      // json_encode 나 json_decode 적용시 데이타는 모두 utf-8, stdClass Object
/**/
echo $output;
?>
